var t = new Array(), a = new Array(), n = 0, e = 0, s = null, tx = null, d = getApp(), o = "1", bjtp2 = null;
var yhzl = new Array();
var tjcs = new Array();
var appid = null;
var tklx;

Page({
  data: {
    tm: null,
    tp: null,
    tk: null,
    xxjs: null,
    bjtp: null,
    num: null,
    csrs: null,
    xpzcs: null,
    csk: null,
    sqqk: "获取头像和昵称",
    tmxh: 0,
    hidden: !0,
    hidden2: !0,
    tmsl: n,
    hidden1: !1,
    hidden3: !1,
    qkxx: !1,
    zdy: null,
    csnr: null,
    usertext: '',
    srk: '',
  },
  onLoad: function (s) {
    var that = this;
    wx.showShareMenu();
    o = "1", t = new Array(), n = 0, e = 0;
    this.setData({
      num: s.num,
    });
    if (s.tm) {
      this.setData({
        tm: s.tm,
        tp: s.tp,
        bjtp: s.bjtp,
        xxjs: s.xxjs,
        num: s.num,
        xpzcs: s.xpzcs,
        zdy: s.zdy,
        csrs: s.csrs
      });
    } else {
      wx.request({
        url: d.globalData.url + "ndzscs/request1/getcs.php",
        data: {
          num: s.num
        },
        method: "GET",
        header: {
          "content-type": "application/json"
        },
        success: function (t) {
          that.setData({
            tm: t.data[0][1],
            tp: t.data[0][4],
            bjtp: t.data[0][5],
            xxjs: t.data[0][3],
            xpzcs: 0,
            zdy: t.data[0][10],
            csrs: t.data[0][6],
          });
        },
        fail: function () {
          wx.showToast({
            title: "连接服务器失败，请重新载入该页面！",
            icon: "none",
            duration: 2e3
          });
        }
      })
    }
    bjtp2 = s.bjtp;
    var i = this;
    if (i.data.xpzcs == "1") {
      tklx = "b"
    } else {
      tklx = "a"
    }
    wx.request({
      url: d.globalData.url + "ndzscs/request1/sstk.php",
      data: {
        tm: tklx + i.data.num
      },
      method: "GET",
      header: {
        "content-type": "application/json"
      },
      success: function (t) {
        a = t.data;
        for (var e = 0; null != t.data[e]; e++) n += 1;
        1 == n && i.setData({
          csk: t.data[0],
          tmsl: n,
          hidden: !1,
          hidden1: !0,
          hidden2: !0,
          hidden3: !1
        }), i.setData({
          csk: t.data[0],
          tmsl: n
        });
      },
      fail: function () {
        wx.showToast({
          title: "连接服务器失败，请重新载入该页面！",
          icon: "none",
          duration: 2e3
        });
      }
    })
  },
  onReady: function () {
    var o = this;
    d.globalData.userInfo && (s = d.globalData.userInfo.nickName, tx = d.globalData.userInfo.avatarUrl,
      o.setData({
        sqqk: "已成功获取头像和昵称"
      }));
    if (d.globalData.appid == null) {
      wx.login({
        success: function (n) {
          var code1 = n.code;
          wx.request({
            url: d.globalData.url + "ndzscs/phb/hqopenid.php",
            method: "GET",
            header: {
              "content-type": "application/json"
            },
            data: {
              code: code1
            },
            success: function (s) {
              appid = s.data;
              d.globalData.appid = s.data;
            }
          }) //获取openid
        }
      });
    } else {
      appid = d.globalData.appid;
    }//提前加载成功
    if (d.globalData.csnr == null) {
      wx.request({
        url: d.globalData.url + "ndzscs/request1/main.php",
        method: "GET",
        header: {
          "content-type": "application/json"
        },
        success: function (c) {
          for (var i = 0; i < 15; i++) {
            tjcs[i] = c.data[i];
          }
          o.setData({
            csnr: tjcs
          })
        }
      })//获取推荐测试
    } else {
      for (var i = 0; i < 10; i++) {
        tjcs[i] = d.globalData.csnr[i];
      }
      o.setData({
        csnr: tjcs
      })
    }//提前加载成功
  },
  onShareAppMessage: function () { //分享代码
    return {
      title: this.data.tm,
      path: "/pages/main/main?tm=" + this.data.tm + "&tp=" + this.data.tp + "&bjtp=" + bjtp2 + "&xxjs=" + this.data.xxjs + "&num=" + this.data.num + "&xpzcs=" + this.data.xpzcs + "&zdy=" + this.data.zdy + "&csrs=" + this.data.csrs,
    };
  },
  chang: function (s) {
    var i = this;
    var d = s.detail.value;
    if (d == undefined) {
      d = s.currentTarget.id;
      i.setData({
         srk: '',
      });
    }
    if (d == '') {
      wx.showToast({
        title: "请输入内容！",
        icon: "none",
        duration: 2e3
      });
      return;
    }
    if (e < n - 1) {
      t[e] = d, e += 1, setTimeout(function () {
        i.setData({
          csk: a[e],
          tmxh: e,
          qkxx: !1,
          usertext: '',
        });
      }, 300);
    } else {
      t[e] = d, setTimeout(function () {
        i.setData({
          hidden: !0,
          hidden2: !1,
          hidden3: !0,
          usertext: '',
        });
      }, 300);
    }
  },
  chang2: function (t) {
    o = t.detail.value;
  },
  onGotUserInfo: function (t) {
    null != t.detail.userInfo && (s = t.detail.userInfo.nickName, tx = t.detail.userInfo.avatarUrl,
      d.globalData.userInfo = t.detail.userInfo, this.setData({ sqqk: "已成功获取头像和昵称" })
    );
  },
  kscs: function () {
    if (null == s || null == tx) wx.showToast({
      title: "请点击获取头像和昵称，进行授权",
      icon: "none",
      duration: 2e3
    });
    else {
      var a = this;
      wx.showLoading({
        title: "正在批改测试题..."
      }), wx.request({
        url: d.globalData.url + "ndzscs/request2/" + tklx + this.data.num + ".php",
        data: {
          tm: t, name: s, id: appid, tx: tx,
        },
        method: "GET",
        header: {
          "content-type": "application/json;charset=utf-8"
        },
        success: function (t) {
          if (tklx == "a") {
            wx.request({
              url: d.globalData.url + "ndzscs/request1/sccscs.php",
              data: {
                tm: a.data.num
              },
              method: "GET",
              header: {
                "content-type": "application/json;charset=utf-8"
              },
              success: function () {
                if (t.data.df == 'ldt') {
                  wx.navigateTo({
                    url: "/pages/bgy3/bgy3?csm=" + t.data.csm + "&bq1=" + t.data.bq1 + "&bq2=" + t.data.bq2 + "&bq3=" + t.data.bq3 + "&bq4=" + t.data.bq4 + "&bq5=" + t.data.bq5 + "&bq6=" + t.data.bq6 + "&bq7=" + t.data.bq7 + "&bq8=" + t.data.bq8 + "&pf1=" + t.data.pf1 + "&pf2=" + t.data.pf2 + "&pf3=" + t.data.pf3 + "&pf4=" + t.data.pf4 + "&pf5=" + t.data.pf5 + "&pf6=" + t.data.pf6 + "&pf7=" + t.data.pf7 + "&pf8=" + t.data.pf8 + "&ztpj=" + t.data.ztpj + "&tms=" + a.data.tm + "&tps=" + a.data.tp + "&bjtps=" + bjtp2 + "&xxjss=" + a.data.xxjs + "&nums=" + a.data.num + "&xpzcss=" + a.data.xpzcs + "&zdys=" + a.data.zdy + "&csrs=" + a.data.csrs,
                  });
                } //跳转到雷达图
                else if (t.data.df == 'fwbjx') {
                  d.globalData.fwbjxtext = t.data.ztpj;
                  wx.navigateTo({
                    url: "/pages/fwbjx/fwbjx?" + "tms=" + a.data.tm + "&tps=" + a.data.tp + "&bjtps=" + bjtp2 + "&xxjss=" + a.data.xxjs + "&nums=" + a.data.num + "&xpzcss=" + a.data.xpzcs + "&zdys=" + a.data.zdy + "&csrs=" + a.data.csrs,
                  });
                } //跳转到富文本
                else {
                  if (t.data.bjtp == null) { //跳转1 背景图片为自带
                    wx.navigateTo({
                      url: "/pages/bgy/bgy?csm=" + t.data.csm + "&dfjs=" + t.data.dfjs + "&bq1=" + t.data.bq1 + "&bq2=" + t.data.bq2 + "&bq3=" + t.data.bq3 + "&bq4=" + t.data.bq4 + "&bq5=" + t.data.bq5 + "&df=" + t.data.df + "&ztpj=" + t.data.ztpj + "&nickname=" + s + "&bjtp=" + o + "&tms=" + a.data.tm + "&tps=" + a.data.tp + "&bjtps=" + bjtp2 + "&xxjss=" + a.data.xxjs + "&nums=" + a.data.num + "&xpzcss=" + a.data.xpzcs + "&zdys=" + a.data.zdy + "&csrs=" + a.data.csrs,
                    })
                  } else { //跳转2 自定义背景图片及格式
                    wx.navigateTo({
                      url: "/pages/bgy/bgy?csm=" + t.data.csm + "&dfjs=" + t.data.dfjs + "&bq1=" + t.data.bq1 + "&bq2=" + t.data.bq2 + "&bq3=" + t.data.bq3 + "&bq4=" + t.data.bq4 + "&bq5=" + t.data.bq5 + "&df=" + t.data.df + "&ztpj=" + t.data.ztpj + "&nickname=" + s + "&bjtp=" + t.data.bjtp + "&tms=" + a.data.tm + "&tps=" + a.data.tp + "&bjtps=" + bjtp2 + "&xxjss=" + a.data.xxjs + "&nums=" + a.data.num + "&xpzcss=" + a.data.xpzcs + "&zdys=" + a.data.zdy + "&csrs=" + a.data.csrs,
                    })
                  }
                } //正常跳转
              }
            });
          } else { //跳转到小瓶子测试
            wx.navigateTo({
              url: "/pages/bgy2/bgy2?csm=" + t.data.csm + "&dfjs=" + t.data.dfjs + "&bq1=" + t.data.bq1 + "&bq2=" + t.data.bq2 + "&bq3=" + t.data.bq3 + "&bq4=" + t.data.bq4 + "&bq5=" + t.data.bq5 + "&bq6=" + t.data.bq6 + "&bq7=" + t.data.bq7 + "&bq8=" + t.data.bq8 + "&bq9=" + t.data.bq9 + "&bq10=" + t.data.bq10 + "&bq11=" + t.data.bq11 + "&bq12=" + t.data.bq12 + "&pf1=" + t.data.pf1 + "&pf2=" + t.data.pf2 + "&pf3=" + t.data.pf3 + "&pf4=" + t.data.pf4 + "&pf5=" + t.data.pf5 + "&pf6=" + t.data.pf6 + "&pf7=" + t.data.pf7 + "&pf8=" + t.data.pf8 + "&pf9=" + t.data.pf9 + "&pf10=" + t.data.pf10 + "&pf11=" + t.data.pf11 + "&pf12=" + t.data.pf12 + "&df=" + t.data.df + "&nickname=" + s + "&bjtp=" + o + "&tms=" + a.data.tm + "&tps=" + a.data.tp + "&bjtps=" + bjtp2 + "&xxjss=" + a.data.xxjs + "&nums=" + a.data.num + "&xpzcss=" + a.data.xpzcs + "&zdys=" + a.data.zdy + "&csrs=null",
            });
          }
        },
        fail: function () {
          wx.showToast({
            title: "连接服务器失败，请重新载入该页面！",
            icon: "none",
            duration: 2e3
          });
        }
      }), wx.hideLoading();
    }
  },
  ksdt: function () {
    this.setData({
      hidden: !1,
      hidden1: !0,
      hidden3: !0
    });
  },
  qhsyt: function () {
    var t = this;
    0 != e && (e -= 1, t.setData({
      csk: a[e],
      tmxh: e,
      qkxx: !1
    }));
  },
  qhsyt1: function () {
    var t = this;
    t.setData({
      csk: a[e],
      tmxh: e,
      qkxx: !1,
      hidden: !1,
      hidden2: !0
    }), 1 == n && t.setData({
      hidden3: !1
    });
  },
  kscss: function (t) {
    var o = t.currentTarget.dataset.index;
    wx.redirectTo({
      url: "/pages/ceshi/ceshi?tm=" + this.data.csnr[o][1] + "&tp=" + this.data.csnr[o][4] + "&bjtp=" + this.data.csnr[o][5] + "&xxjs=" + this.data.csnr[o][3] + "&num=" + this.data.csnr[o][0] + "&xpzcs=0" + "&zdy=" + this.data.csnr[o][10] + "&csrs=" + this.data.csnr[o][6]
    });
  },
  getInput: function (o) {
    this.setData({
      usertext: o.detail.value,
    })
  },
});